﻿#region Copyright ©2008-2011, Technische Universitaet Muenchen
// ====================================================================================================
//
// Last Changed by       $Author: then $
// Last Changed Date     $LastChangedDate: 2009-06-15 08:45:45 +0200 (Mon, 15 Jun 2009) $
// Last Changed Revision $Rev: 194 $
//
// ====================================================================================================
#endregion

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;

namespace Tum.CollabXT.Wizard
{
    /// <summary>
    /// Interaction logic for WizardWindow.xaml
    /// </summary>
    public partial class WizardWindow : Window
    {
        /// <summary>
        /// Log which is used to track wizard actions
        /// </summary>
        Log WizardLog;

        /// <summary>
        /// Workflow which is used for the conversion
        /// </summary>
        ConversionWorkflow Conversion;

        /// <summary>
        /// Splash window.
        /// </summary>
        SplashWindow SplashWnd;


        /// <summary>
        /// Constructor
        /// </summary>
        public WizardWindow()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Event handler: Wizard closed.
        /// </summary>
        private void Window_Closed(object sender, EventArgs e)
        {
            WizardLog.Close();
            WizardLog.Dispose();
        }

        /// <summary>
        /// Event handler: Wizard window loaded.
        /// </summary>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SplashWnd = new SplashWindow();
            SplashWnd.Owner = this;
            SplashWnd.Show();


            //Open log
            WizardLog = new Log(Path.GetTempPath() + "/PET-Log.txt");

            //Create conversion workflow
            Conversion = new ConversionWorkflow(wizardFrame, buttonBack, buttonNext, WizardLog);
            Conversion.WorkflowTitleChanged += new ConversionWorkflow.WorkflowTitleChangedDelegate(Conversion_WorkflowTitleChanged);


            SplashWnd.Close();
        }

        /// <summary>
        /// Event handler: Workflow title changed.
        /// </summary>
        void Conversion_WorkflowTitleChanged(string newTitle)
        {
            this.Title = "PET - " + newTitle;
        }

        /// <summary>
        /// Event handler: About box button clicked.
        /// </summary>
        private void buttonHelp_Click(object sender, RoutedEventArgs e)
        {
            AboutBox ab = new AboutBox(Conversion.PluginMgr);
            ab.Owner = this;
            ab.ShowDialog();
        }
    }
}
